<template>
  <div>
    <div class="icon">
      <i class="el-icon-edit"></i>
      学生信息
    </div>
    <div class="tables">
      <el-row type="flex" justify="center">
        <el-col :span="10">
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="学号">
              <el-input v-model="form.studentNumber" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="姓名">
              <el-input v-model="form.studentName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="院系">
              <el-input v-model="form.departmentName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="专业">
              <el-input v-model="form.majorName" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="班级">
              <el-input v-model="form.className" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="Email">
              <el-input v-model="form.studentEmail"></el-input>
            </el-form-item>
            <el-form-item label="日期" align="left">
              <el-date-picker
                v-model="form.studentBirthday"
                type="date"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item align="left" label="性别">
              <el-radio disabled v-model="form.studentSex" label="1">男</el-radio>
              <el-radio disabled v-model="form.studentSex" label="0">女</el-radio>
            </el-form-item>
            <el-form-item label="密码">
              <el-input v-model="form.studentPassword" type="password"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">修改</el-button>
              <el-button>取消</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
    </div>
  </div>
</template>


<script>
  import {get, post} from "../../../common/request";

  export default {
    name: "StudentInfo",
    data() {
      return {
        form: {
          studentNumber: "",
          studentName: "",
          departmentName: "",
          majorName: "",
          className: "",
          studentEmail: "",
          studentBirthday: "",
          studentSex: "1",
          studentPassword: ""
        }
      }
    },
    methods: {
      onSubmit() {
        post("/rc-student/updateStudent", this.form).then(x => {
          console.log(x)
          if (x.code == 1) {
            this.$message.success(x.msg)
          } else {
            this.$message.error(x.msg)
          }
        })
      },
      getData() {
        get("/rc-student/getStudentInfo").then(x => {
          // console.log(x)
          this.form = x.data
          this.form.studentSex = x.data.studentSex + "";
        })
      }
    },
    mounted() {
      this.getData();
    }
  }
</script>


<style scoped>
  .icon {
    color: dimgray;
    line-height: 20px;
    text-align: left;
  }

  .tables {
    background-color: white;
    border-radius: 5px;
    border: 1px solid lightgrey;
    margin-top: 10px;
    padding: 10px 30px 10px 30px;
  }

  el-input {
    text-align: left;
  }
</style>
